<?php

class UserHouse extends CActiveRecord
{

 /*
   * Returns the static model of the specified AR class.
   * @return CActiveRecord the static model class
   */
  public static function model($className=__CLASS__)
  {
    return parent::model($className);
  }

public function relations()
{

return array( 'facilityRoom'=>array(self::HAS_MANY, 'FacilityRoom', 'uh_id','together'=>false),
 'Users'=>array(self::BELONGS_TO, 'Users', 'user_id'));

}
  /**
   * @return string the associated database table name
   */
  public function tableName()
  {
    return 'USER_HOUSE';
  }
    
  public function primaryKey(){
    return 'id';
  } 
  
  
  //   public function findByUserId($userId){
  //   //$record=self::model()->findAll('user_id=:userId', array(':userId'=>$userId));
  //   $record=self::model()->with('Users')->findAll(array(
  //   'condition'=>'user_id=:userId',
  //   'params'=>array(':userId'=>$userId),
  //   'order'=>'inputDate desc'
  //   ));
  //   $array=array();
  //     foreach($record as $r){
  //     $object=new stdClass();
  //     $object->id=$r->id;
  //     $object->hs_id=$r->hs_id;
  //     $object->user_id=$r->user_id;
  //     $object->thumbPath=$r->thumbPath;
  //     $object->inputDate=$r->inputDate;
  //     $object->description=$r->description;
  //     $object->users=$r->Users;
  //     array_push($array,$object);
  //    } 
  //   return $record[0]->users;
  // }
    
  }
  ?>